import {createRouter, createWebHashHistory} from 'vue-router'
import {cancelArr} from "../utils/BSideRequest";

const routes = [{
    path: '/',
    name: 'Index',
    component: () => import('../views/CustomView.vue'),
    meta: {
        title: '智联招聘', // TODO 浏览器标题
        isHeadNavigation: true, // TODO 是否显示tab
        keepAlive: true,
        isLeftMenu: true
    }
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})


// TODO 全局前置守卫
router.beforeEach(async (to) => {
    // TODO 页面切换中断所有请求
    cancelArr.forEach((cancel, index) => {
        cancel()
        cancelArr.splice(index, 1)
    })

    // TODO 设置浏览器Title
    document.title = (to.meta.title ? to.meta.title : '') + ' - All In One'
})

export default router
